package com.machine.filling.function.set;

import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;

import com.machine.filling.R;
import com.machine.filling.base.baseMvp.BaseFragment;
import com.machine.filling.function.init.OilGunList.OilGunListFragment;
import com.machine.filling.function.init.INextFragment;
import com.machine.filling.function.init.activity.MainFrameActivity;
import com.machine.filling.function.main.activity.MainFuelActivity;
import com.machine.filling.function.set.orderList.OrderListFragment;
import com.machine.filling.function.set.versionCheck.VersionCheckFragment;

/**
 * Created by Administrator on 2018/2/1 0001.
 * 系统设置主界面
 */

public class SetFragment extends BaseFragment<SetContract.Presenter> implements SetContract.View, View.OnClickListener {
    /**
     * 查看订单信息
     */
    public static final int REQ_ACT_CHECK_ORDER = 1001;
    /**
     * 允许查看订单
     */
    public static final int RES_ALLOW_CHECK_ORDER = 2001;

    private INextFragment INextFragment;
    private RelativeLayout rl_order_query;
    private RelativeLayout rl_version_check;
    private RelativeLayout rl_system_set;
    private Button bt_back;

    /**
     * @param mIntent
     */
    public SetFragment(Intent mIntent) {
        super(mIntent);
    }

    @Override
    public View initViews() {
        View view = LayoutInflater.from(mActivity).inflate(R.layout.fg_system_set, null);
        rl_order_query = (RelativeLayout) view.findViewById(R.id.rl_order_query);
        rl_version_check = (RelativeLayout) view.findViewById(R.id.rl_version_check);
        rl_system_set = (RelativeLayout) view.findViewById(R.id.rl_system_set);
        bt_back = (Button)view.findViewById(R.id.bt_back);
        rl_order_query.setOnClickListener(this);
        rl_version_check.setOnClickListener(this);
        rl_system_set.setOnClickListener(this);
        bt_back.setOnClickListener(this);
        return view;
    }

    @Override
    public void initDatas() {

    }


    public void setINextFragment(INextFragment INextFragment) {
        this.INextFragment = INextFragment;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.rl_order_query:
//                INextFragment.replaceNext(new Intent(),OrderListFragment.class.getName());
                Intent intent2 = new Intent(mActivity, MainFrameActivity.class);
                intent2.putExtra("isFromSet", true);
                intent2.putExtra("isFillerLogin", true);//是否是加油员登录模式
//                startActivityForResult(intent2,REQ_ACT_CHECK_ORDER);
                startActivity(intent2);
                break;
            case R.id.rl_version_check:
                INextFragment.replaceNext(new Intent(),VersionCheckFragment.class.getName());
                break;
            case R.id.rl_system_set:
                INextFragment.replaceNext(new Intent(),OilGunListFragment.class.getName());
                break;
            case R.id.bt_back:
                mActivity.startActivity(new Intent(mActivity,MainFuelActivity.class));
                break;
        }
    }

//    @Override
//    public void onActivityResult(int requestCode, int resultCode, Intent data) {
//        super.onActivityResult(requestCode, resultCode, data);
//        if (requestCode == SetFragment.REQ_ACT_CHECK_ORDER && resultCode == SetFragment.RES_ALLOW_CHECK_ORDER){
//            INextFragment.replaceNext(new Intent(),OrderListFragment.class.getName());
//        }
//    }
}
